

#include "boost/function.hpp"
#include <iostream>

#define print(msg)\
	::std::cout << (msg) << ::std::endl;

struct int_div { 
  float operator()(int x, int y) const { return ((float)x)/y; }; 
};

struct X {
  int foo(int x) { return (x+6);}
};

int dummy(bool f){ return f?10:5; }

int main(int argc, char** argv){
	//1
	boost::function<float (int x, int y)> f;
	int_div id;
	f = boost::ref(id);
	print( f(5, 3) ); 
	
	//2
	boost::function<float (int x, int y)> f2 = int_div();
	print( f2(5,3) );	

	//3
	boost::function<int (bool f)> h = dummy;
	print( h(false) );
	
	boost::function<int (X*, int)> g = &X::foo;
	X x;
	print( g(&x,5) );
	return 0;
}

